package com.hg.controller;

import com.hg.pojo.ItemCat;
import com.hg.service.IItemCatService;
import com.hg.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品类目 前端控制器
 * </p>
 *
 * @author Baomidou
 * @since 2025-07-30
 */
@RestController
@RequestMapping("/backend/itemCategory")
public class ItemCatController {
    @Autowired
    private IItemCatService itemCatService;

    @RequestMapping("/selectItemCategoryByParentId")
    public Result selectItemCategoryByParentId(@RequestParam(defaultValue = "0") Long id){
        try {
            List<ItemCat> itemCatList = itemCatService.selectItemCategoryByParentId(id);
            return Result.ok(itemCatList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

}
